/**
 * 
 */
package com.fish.web.sight;

import java.util.ArrayList;
import java.util.List;

import com.fish.common.constant.Constant;
import com.fish.common.constant.QueryPage;
import com.fish.common.web.BaseAction;
import com.fish.finance.po.Settlement;
import com.fish.service.sight.SightService;
import com.fish.sight.po.Sight;

/**
 * @author damian
 *
 */
public class SightAction extends BaseAction {
	
	private static final long serialVersionUID = -5854015572556642807L;
	private List<Sight> sightList = new ArrayList<Sight>();
	private SightService sightService;
	private Sight sightQueryForm = new Sight();
	private Sight sightForm;
	private String sightId;
	private Sight sightBean;
	private QueryPage queryPage = new QueryPage();
	
	public String goToSight(){
		return SUCCESS;
	}

	/**
	 * 查询列表
	 * @return
	 */
	public String list(){
		if(!getSessionUser().isAdmin()){
			sightQueryForm.setUserId(getSessionUser().getUserId());
		}
		
		Long count = sightService.querySightCountByObject(sightQueryForm);
		if(count > 0){
			queryPage = new QueryPage(count, Constant.DEFAULT_PAGE_SIZE, queryPage.getCurPage());
		}
		
		sightList = sightService.querySightByObject(sightQueryForm,queryPage);
		return SUCCESS;
	}
	
	/**
	 * 进入新增页面
	 * @return
	 */
	public String create(){
		if(this.sightBean==null){
			this.sightBean=new Sight();
		}
		return SUCCESS;
	}
	
	/**
	 * 保存
	 * @return
	 */
	public String save(){
		if(this.sightForm!=null){
//			this.sightForm.setPostUserId(super.getCurrentUserId());
			this.sightForm.setSightId(super.getNewUUID());
			if(this.sightService.insertSight(this.sightForm)!=null){
//				this.addValueToRequest(retMsg,saveSuccess);
			}
		}
		return SUCCESS;
	}
	
	/**
	 * 进入编辑页面
	 * @return
	 */
	public String edit(){
		this.sightBean=this.sightService.selectSightById(this.sightId);
		return SUCCESS;
	}
	
	/**
	 * 更新
	 * @return
	 */
	public String update(){
		if(this.sightForm!=null){
//			this.sightForm.setUpdateUserId(super.getCurrentUserId());
			if(this.sightService.updateSight(this.sightForm)){
//				this.addValueToRequest(retMsg,updateSuccess);
			}
		}
		return SUCCESS;
	}
	
	/**
	 * 删除
	 * @return
	 */
	public String delete(){
//		if(this.sightService.deleteSight(this.sightId,super.getCurrentUserId())){
////			this.addValueToRequest(retMsg,deleteSuccess);
//		}
		return SUCCESS;
	}

	
	public SightService getSightService() {
		return sightService;
	}

	public void setSightService(SightService sightService) {
		this.sightService = sightService;
	}

	public Sight getSightQueryForm() {
		return sightQueryForm;
	}

	public void setSightQueryForm(Sight sightQueryForm) {
		this.sightQueryForm = sightQueryForm;
	}

	public Sight getSightForm() {
		return sightForm;
	}

	public void setSightForm(Sight sightForm) {
		this.sightForm = sightForm;
	}

	public String getSightId() {
		return sightId;
	}

	public void setSightId(String sightId) {
		this.sightId = sightId;
	}

	public Sight getSightBean() {
		return sightBean;
	}

	public void setSightBean(Sight sightBean) {
		this.sightBean = sightBean;
	}

	public QueryPage getQueryPage() {
		return queryPage;
	}

	public void setQueryPage(QueryPage queryPage) {
		this.queryPage = queryPage;
	}

	public List<Sight> getSightList() {
		return sightList;
	}

	public void setSightList(List<Sight> sightList) {
		this.sightList = sightList;
	}
	
}
